package com.example.admin.yuejian_22.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RatingBar;
import android.widget.TextView;

import com.example.admin.yuejian_22.Bean.ClubList;
import com.example.admin.yuejian_22.R;

import java.util.List;

/**
 * Created by Admin on 2017/10/22.
 */

public class ClubDetail_BFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
   // private List clubList;
   private List clubLists;
    private Context Context;
    private LayoutInflater LayoutInflater;

    public ClubDetail_BFragmentAdapter(Context Context, List clubLists) {
        this.Context = Context;
        this.clubLists = clubLists;
        LayoutInflater = LayoutInflater.from(Context);
    }


    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_club_course, parent, false);
        return new ClubDetail_BFragmentAdapter.ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final ClubList.ClubcourseEntity entity = (ClubList.ClubcourseEntity) clubLists.get(position);
        if (null == entity) return;
        ClubDetail_BFragmentAdapter.ViewHolder viewHolder = (ClubDetail_BFragmentAdapter.ViewHolder) holder;
        viewHolder.name.setText(entity.getCourse_name());
        viewHolder.intro.setText(entity.getIntroduction());
        viewHolder.money.setText(entity.getCourse_price() + "元");
        viewHolder.ratingBar.setRating(Float.parseFloat(entity.getDegree()));
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView name;
        private TextView intro;
        private RatingBar ratingBar;
        private TextView money;

        public ViewHolder(View itemView) {
            super(itemView);
            name = (TextView) itemView.findViewById(R.id.club_course_name);
            intro = (TextView) itemView.findViewById(R.id.club_course_intro);
            ratingBar = (RatingBar) itemView.findViewById(R.id.level_ratingBar);
            money = (TextView) itemView.findViewById(R.id.club_course_money);
        }
    }
    @Override
    public int getItemCount() {

        return clubLists.size();



    }


}
